package com.coolingme.auth.v3builder;

import com.coolingme.auth.Member;
import com.coolingme.auth.v3builder.handler.AuthHandler;
import com.coolingme.auth.v3builder.handler.LoginHandler;
import com.coolingme.auth.v3builder.handler.ValidateHandler;

/**
 * 用户登录认证授权
 *
 * @author wangyue
 * @date 2020-09-23 21:43
 */
public class MemberService {

    public void auth(Member member) {
        AbstractAuthHandler.Builder builder = new AbstractAuthHandler.Builder();

        // 按顺序向责任链中添加处理器
        builder.addHandler(new ValidateHandler())
                .addHandler(new LoginHandler())
                .addHandler(new AuthHandler());

        AbstractAuthHandler chain = builder.build();
        chain.doAuth(member);
    }


}
